package com.wang.gaodeseach;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.txt_location)
    TextView txtLocation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
    }

    @OnClick(R.id.txt_location)
    public void onViewClicked() {
        Intent intent = new Intent(this, SeachActivity.class);
        startActivity(intent);
    }

    //接收消息
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void Event(LocationEventBean location) {
        if (!TextUtils.isEmpty(String.valueOf(location.getAddr()))) {
            txtLocation.setText(location.getLocationname() + location.getAddr());
        }
    }
}
